<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.29
     from name.tnf on 19 December 2010 -->

<TITLE>Name analysis according to scope rules - Environment Module</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000" BACKGROUND="gifs/bg.gif">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0" VALIGN=BOTTOM>
<TR VALIGN=BOTTOM>
<TD WIDTH="160" VALIGN=BOTTOM>
<A HREF="http://eli-project.sourceforge.net/">
<IMG SRC="gifs/elilogo.gif" BORDER=0>
</A>&nbsp;
</TD>
<TD WIDTH="25" VALIGN=BOTTOM>
<img src="gifs/empty.gif" WIDTH=25 HEIGHT=25>
</TD>
<TD ALIGN=LEFT WIDTH="475" VALIGN=BOTTOM>
<A HREF="index.html"><IMG SRC="gifs/title.png" BORDER=0></A>
</TD>
<!-- |DELETE FOR SOURCEFORGE LOGO|
<TD>
<a href="http://sourceforge.net/projects/eli-project">
<img
  src="http://sflogo.sourceforge.net/sflogo.php?group_id=70447&amp;type=13"
  width="120" height="30"
  alt="Get Eli: Translator Construction Made Easy at SourceForge.net.
    Fast, secure and Free Open Source software downloads"/>
</a>
</TD>
|DELETE FOR SOURCEFORGE LOGO| -->
</TR>
</TABLE>

<HR size=1 noshade width=785 align=left>
<TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0>
<TR>
<TD VALIGN=TOP WIDTH="160">
<h4>General Information</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="index.html">Eli: Translator Construction Made Easy</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="gindex_1.html#SEC1">Global Index</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="faq_toc.html" >Frequently Asked Questions</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Tutorials</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="EliRefCard_toc.html">Quick Reference Card</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="novice_toc.html">Guide For new Eli Users</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="news_toc.html">Release Notes of Eli</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="nametutorial_toc.html">Tutorial on Name Analysis</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="typetutorial_toc.html">Tutorial on Type Analysis</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Reference Manuals</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ui_toc.html">User Interface</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="pp_toc.html">Eli products and parameters</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lidoref_toc.html">LIDO Reference Manual</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Libraries</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lib_toc.html">Eli library routines</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="modlib_toc.html">Specification Module Library</a></td></tr>
</table>

<h4>Translation Tasks</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lex_toc.html">Lexical analysis specification</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="syntax_toc.html">Syntactic Analysis Manual</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="comptrees_toc.html">Computation in Trees</a></td></tr>
</table>

<h4>Tools</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lcl_toc.html">LIGA Control Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="show_toc.html">Debugging Information for LIDO</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="gorto_toc.html">Graphical ORder TOol</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="fw_toc.html">FunnelWeb User's Manual</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ptg_toc.html">Pattern-based Text Generator</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="deftbl_toc.html">Property Definition Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="oil_toc.html">Operator Identification Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="tp_toc.html">Tree Grammar Specification Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="clp_toc.html">Command Line Processing</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="cola_toc.html">COLA Options Reference Manual</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="idem_toc.html">Generating Unparsing Code</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="mon_toc.html">Monitoring a Processor's Execution</a> </td></tr>
</table>

<h4>Administration</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="sysadmin_toc.html">System Administration Guide</a> </td></tr>
</table>

<HR WIDTH="100%">
<A HREF="mailto:eli-project-users@lists.sourceforge.net">
<IMG SRC="gifs/button_mail.gif" BORDER=0 ALIGN="left"></A>
<A HREF="index.html"><IMG SRC="gifs/home.gif" BORDER=0 ALIGN="right"></A>

</TD>
<TD VALIGN=TOP WIDTH="25"><img src="gifs/empty.gif" WIDTH=25 HEIGHT=25></TD>

<TD VALIGN=TOP WIDTH="600">
<H1>Name analysis according to scope rules</H1>
<P>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="name_7.html"><IMG SRC="gifs/prev.gif" ALT="Previous Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="name_9.html"><IMG SRC="gifs/next.gif" ALT="Next Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="name_toc.html"><IMG SRC="gifs/up.gif" ALT="Table of Contents" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT="">
<HR size=1 noshade width=600 align=left>
<H1><A NAME="SEC20" HREF="name_toc.html#SEC20">Environment Module</A></H1>
<A NAME="IDX230"></A>
<A NAME="IDX231"></A>
<A NAME="IDX232"></A>
<A NAME="IDX233"></A>
<P>
This module implements a standard contour model for name analysis.  The
data structure is a tree of <DFN>scopes</DFN>, each of which can contain an
arbitrary number of definitions.  A definition is a binding of an
identifier to an object in the definition table 
(see  <A HREF="deftbl_toc.html">PDL Reference Manual</A>).
For an identifier <CODE>idn</CODE> and a scope <CODE>sc</CODE>
there is at most one binding in <CODE>sc</CODE>.
<A NAME="IDX234"></A>
<P>
The environment module provides operations for
building scope trees, adding definitions to specific scopes, and
searching individual scopes or sequences of scopes for the binding of
a particular identifier. Inheritance relations can be established
between scopes to support object-oriented name analysis.
<A NAME="IDX235"></A>
<P>
The module is capable of building multiple trees of scopes
in order to model distinct name spaces, such that bindings
in one tree do not effect the lookup in another tree.
<P>
The module places no constraints on the sequence of construction, 
definition and lookup operations; there is one exception: an
inheritance relation may not be established for a scope that
has already been involved in a lookup operation.
<P>
The module implements certain lookup operations such that
linear search through several scopes is avoided in order to
reduce the amortized asymptotic cost of name analysis.
This effect on efficiency can be lost if the sequence of
those lookup operations arbitrarily often switches the
scopes they are applied to.
<P>
The modules described in the Name Analysis Library
(see  <A HREF="name_toc.html">Name Analysis of Specification Module Library: Name Analysis</A>)
provide solutions for common name analysis tasks based on this
environment module. 
If they are used the interface of this 
module is available for use in <CODE>.lido</CODE> specifications;
otherwise the interface is made available by adding
<A NAME="IDX236"></A>
<CODE>$/Name/envmod.specs</CODE> to the processor specification.
In C modules the interface of the environment module is introduced
by <CODE>#include "envmod.h"</CODE>.
<P>
<H2><A NAME="SEC21" HREF="name_toc.html#SEC21">Exported types and values</A></H2>
<P>
The following types and constant values are provided to represent name
analysis data:
<A NAME="IDX237"></A>
<A NAME="IDX238"></A>
<P>
<DL COMPACT>
<DT><CODE>Environment</CODE>
<DD>A pointer to a node in the tree of scopes.
It is used either to refer to a single scope, or
to refer to a scope and all the scopes that are visible from it
(i.e. its ancestors in the tree and the scopes that are inherited 
by each).
<A NAME="IDX239"></A>
<P>
<DT><CODE>NoEnv</CODE>
<DD>A constant of type <CODE>Environment</CODE> that represents no environment.
<A NAME="IDX240"></A>
<A NAME="IDX241"></A>
<P>
<DT><CODE>Binding</CODE>
<DD>A pointer to a triple
<CODE>(int idn, Environment sc, DefTableKey key)</CODE> 
that represents the binding
of the identifier <CODE>idn</CODE>
in the scope pointed to by <CODE>sc</CODE>
to the entity <CODE>key</CODE>.
<A NAME="IDX242"></A>
<P>
<DT><CODE>NoBinding</CODE>
<DD>A constant of type <CODE>Binding</CODE> that represents no binding.
<A NAME="IDX243"></A>
<A NAME="IDX244"></A>
<P>
<DT><CODE>InheritPtr</CODE>
<DD>An opaque type used to traverse inheritance relations.
<A NAME="IDX245"></A>
<P>
<DT><CODE>NoInherit</CODE>
<DD>A constant of type <CODE>InheritPtr</CODE> that indicates the end of an
inheritance traversal.
</DL>
<P>
<H2><A NAME="SEC22" HREF="name_toc.html#SEC22">Operations to build the scope tree</A></H2>
<P>
The following operations are provided for constructing the 
tree of scopes:
<A NAME="IDX246"></A>
<P>
<DL COMPACT>
<DT><CODE>Environment NewEnv ()</CODE>
<DD>A function that creates a new tree consisting of a single, empty scope and
returns a reference to that empty scope.  
<A NAME="IDX247"></A>
<P>
<DT><CODE>Environment NewScope (Environment env)</CODE>
<DD>A function that creates a new empty scope as a child of the scope
pointed to by <CODE>env</CODE> and returns a reference to that empty scope.
</DL>
<P>
<H2><A NAME="SEC23" HREF="name_toc.html#SEC23">Operations to establish inheritance</A></H2>
<P>
An inheritance relation from scope <CODE>fromcl</CODE> to scope <CODE>tocl</CODE> means
that the scope <CODE>tocl</CODE> inherits the bindings of the scope
<CODE>fromcl</CODE>.
The following operations are provided to establish and to check
inheritance relations:
<A NAME="IDX248"></A>
<A NAME="IDX249"></A>
<P>
<DL COMPACT>
<DT><CODE>int InheritClass (Environment tocl, Environment fromcl)</CODE>
<DD>A function that establishes an inheritance relation
from the scope <CODE>fromcl</CODE> to the scope <CODE>tocl</CODE>
if and only if
<P>
<UL>
<DT><CODE></CODE>
<DD><CODE>tocl</CODE> and <CODE>fromcl</CODE> are different scopes in the same tree of scopes
<P>
<DT><CODE></CODE>
<DD>the graph of inheritance relations remains acyclic when adding the relation
<P>
<DT><CODE></CODE>
<DD>the scope <CODE>tocl</CODE> has not yet been involved in a lookup for a binding.
</UL>
<P>
<CODE>InheritClass</CODE> returns 1 if the inheritance relation
could be established; otherwise it returns 0.
<A NAME="IDX250"></A>
<A NAME="IDX251"></A>
<P>
<DT><CODE>int Inheritsfrom (Environment tocl, Environment fromcl)</CODE>
<DD>A function that returns 1 if <CODE>tocl</CODE> and <CODE>fromcl</CODE> are the same scopes,
or if there is a direct or indirect inheritance relation from
the scope <CODE>fromcl</CODE> to the scope <CODE>tocl</CODE>.
Otherwise <CODE>Inheritsfrom</CODE> returns 0.
After a call of <CODE>Inheritsfrom</CODE>, no further inheritance relation
can be established for <CODE>tocl</CODE> or <CODE>fromcl</CODE>.
</DL>
<P>
<H2><A NAME="SEC24" HREF="name_toc.html#SEC24">Operations to establish bindings</A></H2>
<P>
The following operations are provided to establish a binding
within a scope:
<A NAME="IDX252"></A>
<A NAME="IDX253"></A>
<P>
<DL COMPACT>
<DT><CODE>Binding BindKey (Environment env, int idn, DefTableKey key)</CODE>
<DD>A function that checks the scope referenced by its <CODE>env</CODE> argument for a
binding of the identifier specified by its <CODE>idn</CODE> argument.  
If no such binding is found, a binding of the identifier <CODE>idn</CODE>
to the definition table object specified by <CODE>key</CODE> is added to scope
<CODE>env</CODE>. <CODE>BindKey</CODE> returns the value <CODE>NoBinding</CODE>
if a binding already exists, and returns the new binding otherwise.
<A NAME="IDX254"></A>
<A NAME="IDX255"></A>
<P>
<DT><CODE>int AddIdn (Environment env, int idn, DefTableKey key)</CODE>
<DD>A macro that calls <CODE>BindKey</CODE>.
<CODE>AddIdn</CODE> returns the value <CODE>0</CODE> if <CODE>BindKey</CODE> returns
<CODE>NoBinding</CODE>, and returns <CODE>1</CODE> otherwise.
<A NAME="IDX256"></A>
<A NAME="IDX257"></A>
<P>
<DT><CODE>Binding BindKeyInScope (Environment env, int idn, DefTableKey key)</CODE>
<DD>A function that has the same effect as <CODE>BindKey</CODE>.
<CODE>BindKeyInScope</CODE> should be used for efficiency reasons
if bindings are established in several different scopes before
lookups are performed in them.
<A NAME="IDX258"></A>
<A NAME="IDX259"></A>
<P>
<DT><CODE>Binding BindIdn (Environment env, int idn)</CODE>
<DD>A function that checks the scope referenced by its <CODE>env</CODE> argument for a
binding of the identifier specified by its <CODE>idn</CODE> argument.  
If no such binding is found,
<CODE>BindIdn</CODE> obtains a value from <CODE>NewKey()</CODE> and 
binds <CODE>idn</CODE> to that value in scope <CODE>env</CODE>.  
<CODE>BindIdn</CODE> returns the 
the binding associated with <CODE>idn</CODE>.
<A NAME="IDX260"></A>
<A NAME="IDX261"></A>
<P>
<DT><CODE>DefTableKey DefineIdn (Environment env, int idn)</CODE>
<DD>A macro that calls <CODE>BindIdn</CODE> and returns the key of the binding
returned by <CODE>BindIdn</CODE>.
<A NAME="IDX262"></A>
<A NAME="IDX263"></A>
<P>
<DT><CODE>Binding BindInScope (Environment env, int idn)</CODE>
<DD>A function that has the same effect as <CODE>BindIdn</CODE>.
<CODE>BindInScope</CODE> should be used for efficiency reasons
if bindings are established in several different scopes before
lookups are performed in them.
</DL>
<P>
These operations are very similar, but they differ in two aspects:
<P>
<UL>
<LI>
The key for the new binding is given as an argument
(<CODE>BindKey</CODE>, <CODE>AddIdn</CODE>, <CODE>BindKeyInScope</CODE>), or a
new key is created for the new binding (<CODE>BindIdn</CODE>, <CODE>DefineIdn</CODE>,
<CODE>BindInScope</CODE>).
<P>
<LI>
Functions that should be preferred for efficiency reasons
if several operations on one scope occur in sequence
(<CODE>BindKey</CODE>, <CODE>AddIdn</CODE>, <CODE>BindIdn</CODE>, <CODE>DefineIdn</CODE>),
or if scopes are arbitrarily switched between operations
(<CODE>BindKeyInScope</CODE>, <CODE>BindInScope</CODE>).
</UL>
<P>
<CODE>DefineIdn</CODE> and <CODE>AddIdn</CODE>
are provided for compatibility with previous versions
of the environment module.
<P>
<H2><A NAME="SEC25" HREF="name_toc.html#SEC25">Operations to find bindings</A></H2>
<P>
The following operations are provided to lookup bindings for
given identifiers.
For ease of understanding they
are described here as if the bindings of scopes were traversed
in a linear search. In fact the implementation avoids
such linear search where possible:
<A NAME="IDX264"></A>
<A NAME="IDX265"></A>
<P>
<DL COMPACT>
<DT><CODE>Binding BindingInScope (Environment env, int idn)</CODE>
<DD>A function that checks the scope referenced by its <CODE>env</CODE> argument
for a binding of the identifier specified by its <CODE>idn</CODE> argument.
If no binding for <CODE>idn</CODE> is found,
the scopes that are directly or indirectly
inherited by <CODE>env</CODE> are searched.
During that search, a scope <CODE>tocl</CODE>
is considered before a scope <CODE>fromcl</CODE> if <CODE>tocl</CODE>
inherits from <CODE>fromcl</CODE>.
The first binding found is returned;
if no binding is found then <CODE>NoBinding</CODE> is returned.
<A NAME="IDX266"></A>
<A NAME="IDX267"></A>
<P>
<DT><CODE>DefTableKey KeyInScope (Environment env, int idn)</CODE>
<DD>A macro that calls <CODE>BindingInScope</CODE> and returns the key of the
binding found.
<CODE>NoKey</CODE> is returned if no binding is found by <CODE>BindingInScope</CODE>.
<A NAME="IDX268"></A>
<A NAME="IDX269"></A>
<P>
<DT><CODE>Binding BindingInEnv (Environment env, int idn)</CODE>
<DD>A function that has the same effect as <CODE>BindingInScope</CODE> except that
if no binding for <CODE>idn</CODE> is found for scope <CODE>env</CODE> 
then the search continues as if <CODE>BindingInScope</CODE>
was applied successively to ancestors of <CODE>env</CODE> in the tree of scopes.
<A NAME="IDX270"></A>
<A NAME="IDX271"></A>
<P>
<DT><CODE>DefTableKey KeyInEnv (Environment env, int idn)</CODE>
<DD>A macro that calls <CODE>BindingInEnv</CODE> and returns the key of the
binding found.
<CODE>NoKey</CODE> is returned if no binding is found by <CODE>BindingInEnv</CODE>.
</DL>
<P>
These operations are very similar, but they differ in one aspect:
<P>
<UL>
<LI>
Only the scope given as argument and those scopes it inherits 
from are considered for the lookup 
(<CODE>BindingInScope</CODE>, <CODE>KeyInScope</CODE>), 
or the scope given as argument, its ancestors in the tree of scopes,
and those scopes they inherit from are considered for the lookup 
(<CODE>BindingInEnv</CODE>, <CODE>KeyInEnv</CODE>).
</UL>
<P>
<CODE>KeyInScope</CODE> and <CODE>KeyInEnv</CODE> are
are provided for compatibility with previous versions
of the environment module.
<P>
<H2><A NAME="SEC26" HREF="name_toc.html#SEC26">Operations to find additional bindings</A></H2>
<P>
The following operations find further bindings that
are related in some way to a given one:
<A NAME="IDX272"></A>
<A NAME="IDX273"></A>
<P>
<DL COMPACT>
<DT><CODE>Binding OverridesBinding (Binding bind)</CODE>
<DD>A function that yields a hidden binding.
Let <CODE>bind</CODE> be a binding of identifier <CODE>idn</CODE> in a scope <CODE>e</CODE>.
Then <CODE>OverridesBinding</CODE> returns the value that
<CODE>BindingInEnv(e,idn)</CODE> would have returned if the binding <CODE>bind</CODE>
had not existed.
<A NAME="IDX274"></A>
<A NAME="IDX275"></A>
<P>
<DT><CODE>Binding NextInhBinding (Environment env, Binding bind)</CODE>
<DD>A function that yields a binding that is also visible
due to multiple inheritance relations.
Let <CODE>bind</CODE> be a binding of identifier <CODE>idn</CODE> in a scope <CODE>e</CODE>
that has been obtained by a call <CODE>BindingInScope(env, idn)</CODE>,
<CODE>BindingInEnv(env, idn)</CODE>, or <CODE>NextInhBinding(env, idn)</CODE>,
and let <CODE>tocl</CODE> be <CODE>env</CODE> or its next ancestor that
inherits from <CODE>e</CODE>.
Then <CODE>NextInhBinding</CODE> returns a binding of identifier <CODE>idn</CODE>,
if any, in a scope <CODE>ep</CODE> that is inherited by <CODE>tocl</CODE>
but not by <CODE>e</CODE>;
otherwise <CODE>NoBinding</CODE> is returned.
<A NAME="IDX276"></A>
<A NAME="IDX277"></A>
<P>
<DT><CODE>DefTableKey NextInhKey (Environment env, int idn, DefTableKey key)</CODE>
<DD>A function that has the same effect as <CODE>NextInhBinding</CODE>, except that
the keys of bindings (instead of the bindings themselves)
are supplied and returned.
</DL>
<P>
<H2><A NAME="SEC27" HREF="name_toc.html#SEC27">Operations to examine environments</A></H2>
<P>
The following operations are provided to obtain information from
environments:
<A NAME="IDX278"></A>
<P>
<DL COMPACT>
<DT><CODE>Binding DefinitionsOf(Environment env)</CODE>
<DD>A function that returns the first binding of the scope <CODE>env</CODE>.
It returns <CODE>NoBinding</CODE> if <CODE>env</CODE> is <CODE>NoEnv</CODE> or
if no identifiers are bound in <CODE>env</CODE>.
<A NAME="IDX279"></A>
<P>
<DT><CODE>Binding NextDefinition(Binding b)</CODE>
<DD>A function that returns the next binding of the scope <CODE>EnvOf(b)</CODE>.
It returns <CODE>NoBinding</CODE> if <CODE>b</CODE> is <CODE>NoBinding</CODE> or
if <CODE>b</CODE> is the last binding of <CODE>EnvOf(b)</CODE>.
<A NAME="IDX280"></A>
<P>
<DT><CODE>int IdnOf(Binding b)</CODE>
<DD>A function that returns the identifier bound by <CODE>b</CODE>.
It returns <CODE>NoIdn</CODE> if <CODE>b</CODE> is <CODE>NoBinding</CODE>.
<A NAME="IDX281"></A>
<P>
<DT><CODE>DefTableKey KeyOf(Binding b)</CODE>
<DD>A function that returns the key bound by <CODE>b</CODE>.
It returns <CODE>NoKey</CODE> if <CODE>b</CODE> is <CODE>NoBinding</CODE>.
<A NAME="IDX282"></A>
<P>
<DT><CODE>Environment EnvOf(Binding b)</CODE>
<DD>A function that returns the environment containing <CODE>b</CODE>.
It returns <CODE>NoEnv</CODE> if <CODE>b</CODE> is <CODE>NoBinding</CODE>.
<A NAME="IDX283"></A>
<P>
<DT><CODE>Environment ParentOf(Environment env)</CODE>
<DD>A function that returns the parent of <CODE>env</CODE> in a tree of scopes.
It returns <CODE>NoEnv</CODE> if <CODE>env</CODE> is <CODE>NoEnv</CODE> or
if <CODE>env</CODE> is the root of the tree.
<A NAME="IDX284"></A>
<P>
<DT><CODE>DefTableKey SetKeyOfEnv(Environment env, DefTableKey k)</CODE>
<DD>A function that associates the key <CODE>k</CODE> with the scope <CODE>env</CODE>.
It returns <CODE>k</CODE> unless <CODE>env</CODE> is <CODE>NoEnv</CODE>;
in that case it returns <CODE>NoKey</CODE>.
<A NAME="IDX285"></A>
<P>
<DT><CODE>DefTableKey KeyOfEnv(Environment env)</CODE>
<DD>A function that returns the key <CODE>k</CODE> associated with the scope
<CODE>env</CODE> by the most recent operation <CODE>SetKeyOfEnv(env,k)</CODE>.
It returns <CODE>NoKey</CODE> if <CODE>env</CODE> is <CODE>NoEnv</CODE> or
if <CODE>SetKeyOfEnv(env,k)</CODE> has never been executed.
<A NAME="IDX286"></A>
<P>
<DT><CODE>int IsClass(Environment env)</CODE>
<DD>A function that returns 1 if the scope <CODE>env</CODE> has been argument of a
call of <CODE>InheritClass</CODE>; otherwise 0 is returned.
<A NAME="IDX287"></A>
<P>
<DT><CODE>InheritPtr DirectInherits(Environment env)</CODE>
<DD>A function that returns the first direct inheritance relation to <CODE>env</CODE>
established by a call of <CODE>InheritClass(env,fromcl)</CODE>.
It returns <CODE>NoInherit</CODE> if <CODE>env</CODE> is <CODE>NoEnv</CODE> or
if <CODE>InheritClass(env,fromcl)</CODE> has never been invoked.
<A NAME="IDX288"></A>
<P>
<DT><CODE>InheritPtr NextInherit(InheritPtr inh)</CODE>
<DD>A function that returns the next direct inheritance relation.
It returns <CODE>NoInherit</CODE> if <CODE>inh</CODE> is <CODE>NoInherit</CODE> or
if there are no more direct inheritances for the given scope.
<A NAME="IDX289"></A>
<P>
<DT><CODE>Environment EnvOfInherit(InheritPtr inh)</CODE>
<DD>A function that returns the scope <CODE>fromcl</CODE>
of the inheritance relation <CODE>inh</CODE>.
</DL>
<P>
<HR size=1 noshade width=600 align=left>
<P>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="name_7.html"><IMG SRC="gifs/prev.gif" ALT="Previous Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="name_9.html"><IMG SRC="gifs/next.gif" ALT="Next Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="name_toc.html"><IMG SRC="gifs/up.gif" ALT="Table of Contents" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT="">
<HR size=1 noshade width=600 align=left>
</TD>
</TR>
</TABLE>

</BODY></HTML>
